package com.sfzlot.dev.netty.bean.data.powerswitch;

import java.util.Date;

import com.sfzlot.dev.netty.bean.inf.Data;
import com.sfzlot.dev.netty.utils.ByteUtil;


/**
 * 设备物理开关请求体
 * Created by pierr on 2017/5/30.
 */
public class PowerSwitchSwitchInData implements Data {
    
    private Date dataCollectTime;	// 数据采集时间
    private int flag;				// 通电开关 0-关；1-开

    public Date getDataCollectTime() {
        return dataCollectTime;
    }

    public void setDataCollectTime(Date dataCollectTime) {
        this.dataCollectTime = dataCollectTime;
    }

	public int getFlag() {
		return flag;
	}

	public void setFlag(int flag) {
		this.flag = flag;
	}

	@Override
	public String toString() {
		return "DeviceSwitchInData [dataCollectTime=" + dataCollectTime + ", flag=" + flag + "]";
	}

	@Override
	public byte[] toBytes(){
		byte[] dateBytes = ByteUtil.timeToBytes(dataCollectTime);
		byte[] flagByte = new byte[1];
		flagByte[0] = Integer.valueOf(flag).byteValue();
		return ByteUtil.addAll(dateBytes, flagByte);
	}

	@Override
	public String transData() {
		return "DeviceSwitchInData(物理开关指令请求体) [请求时间=" + dataCollectTime + ", 物理开关是否有效=" + flag + "]";
	}
}
